package com.zmx.doctor.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.doctor.R;
import com.zmx.doctor.pojo.Trip;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 程序猿：胖胖祥
 * 时 间：2020/7/22  11:04
 * 功 能：
 */
public class TripAdapter extends BaseAdapterRvList<TripAdapter.ViewHolder, Trip> {

    SimpleDateFormat sdFormatter = new SimpleDateFormat("HH:mm");
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    public TripAdapter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(TripAdapter.ViewHolder holder, int listPosition, Trip trip) {

        try {
            holder.time.setText(sdFormatter.format(format.parse(trip.getStarttime())));
        } catch (ParseException e) {

        }

        holder.title.setText(trip.getTitle());

    }

    @NonNull
    @Override
    protected TripAdapter.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {
        TripAdapter.ViewHolder holder = new TripAdapter.ViewHolder(inflater.inflate(R.layout.adapter_trip, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.time)
        TextView time;
        @BindView(R.id.title)
        TextView title;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }


}
